package com.example.selfcontrol.controller.Admin;


import com.example.selfcontrol.config.Response;
import com.example.selfcontrol.entity.Article;
import com.example.selfcontrol.service.Admin.AdminArticleJudge;
import com.example.selfcontrol.service.ArticleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/admin/articles")
@Api(value = "后台视图")
public class AdminArticleController {
    @Autowired
    private AdminArticleJudge adminArticleJudge ;

    @GetMapping("/count")
    @ApiOperation("未审核文章数")
    public int CountArticles() { return adminArticleJudge.CountArticles(); }


    @GetMapping("/unjudge")
    @ApiOperation("后台 | 分页查询没审核的文章")
    public List<Article> UnJudgeArticles(int pageNum, int pageSize) {
        return adminArticleJudge.UnJudgeArticles(pageNum,pageSize) ;
    }

    @GetMapping("/allow")
    @ApiOperation("审核文章 | 1 表示通过 , -1表示不通过")
    public Response AllowArticle(int articleId , int judge) {
        return adminArticleJudge.AllowArticle(articleId ,judge) ;
    }
}
